HLRC: Add activate watch action#33988
Conversation
|
Pinging @elastic/es-core-infra |
pcsanwald
left a comment
There was a problem hiding this comment.
A few small naming suggestions and one test suggestion, but I don't want to block merging on re-review.
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
do we need to override toString here? seems relatively harmless, but wasn't sure if it's necessary.
|
|
||
| } | ||
|
|
||
| // Activate watch that does not exist |
There was a problem hiding this comment.
I'd split this into a separate test case, testActivateWatchThatExists and testActivateWatchThatDoesNotExist
| assertThat(request.getEntity(), nullValue()); | ||
| } | ||
|
|
||
| public void testActivateWatch() { |
There was a problem hiding this comment.
I think testActivateWatchRequestConversion is a clearer name.
hub-cap
left a comment
There was a problem hiding this comment.
Wow im super sorry, i had done a review and forgot to click submit :/
Update to today, and we will very soon have a better way to test responses (you do not have a response test) and to generate docs, in the next day or two. We should hold off until then to merge. Feel free to fix up my nits tho.
| .addPathPartAsIs("_xpack") | ||
| .addPathPartAsIs("watcher") | ||
| .addPathPartAsIs("watch") | ||
| .addPathPartAsIs(activateWatchRequest.getWatchId()) |
There was a problem hiding this comment.
.addPathPart(activateWatchRequest...)
.addPathPartAsIs("_activate")
Looks like you swapped the two of them.
|
|
||
| ValidationException exception = new ValidationException(); | ||
|
|
||
| if (watchId == null) { |
There was a problem hiding this comment.
You should just put these in the constructor (the null check already is) and throw from there instead of here and just not override it
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { |
There was a problem hiding this comment.
Node needed and it really doesnt even do anything, so we can remove it and ToXContent interface
| return Objects.hash(status); | ||
| } | ||
|
|
||
|
|
|
|
||
| } | ||
|
|
||
| // Activate watch that does not exist |
| } | ||
| } | ||
|
|
||
| public void testActivateWatch() throws Exception { |
There was a problem hiding this comment.
We will have a new ay to deal with the docs+test, we should wait to merge until it is merged.
There was a problem hiding this comment.
@hub-cap which is the issue that it is introducing this change?
|
@hub-cap Added response test and changed the docs. I think it is getting closer. Is this change required in 6.x? |
|
Yea we backport all of the HLRC APIs to the current 6.x. Some of them landed in 6.4, most will land in 6.5 |
| /** | ||
| * A request to explicitly activate a watch. | ||
| */ | ||
| public final class ActivateWatchRequest implements Validatable, Closeable { |
There was a problem hiding this comment.
Any reason this is Closeable?
There was a problem hiding this comment.
You may also have a look at TimedRequest, assuming this needs the timeouts (I dont know if it does or not, you would have to research the transport layer action)
|
|
||
| public ActivateWatchRequest(String watchId) { | ||
| if (watchId == null) { | ||
| throw new IllegalArgumentException("Watch identifier is required"); |
There was a problem hiding this comment.
there is a Objects.requireNonNull helper you can use here
| return Objects.hash(status); | ||
| } | ||
|
|
||
| private static final ParseField STATUS_FIELD = new ParseField("status"); |
There was a problem hiding this comment.
This is typically on teh top of these classes.
| new ConstructingObjectParser<>("activate_watch_response", true, | ||
| a -> new ActivateWatchResponse((WatchStatus) a[0])); | ||
|
|
||
| static { |
|
@elasticmachine test this please |
1 similar comment
|
@elasticmachine test this please |
|
@hub-cap The commit cannot be back ported as WatchStatus has not been back ported. If necessary I can coordinate with @jtibshirani to do so. |
|
Just backported it to 6.x in 83e30ee, sorry for the delay! |
* HLRC: Add activate watcher action Adds activate watch action to the high level rest client. Relates #29827
* master: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
* rename-ccr-stats: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
* HLRC: Add activate watcher action Adds activate watch action to the high level rest client. Relates #29827
Adds activate watch action to the high level rest client.
Relates #29827